package com.di.base.controller;

import com.di.base.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@Slf4j
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/order/create")
    public String createOrder() {
        try {
            // 写死参数
            String userId = "U1002";
            String productId = "P10001";
            int count = 2;
            BigDecimal amount = new BigDecimal("99.99");

            orderService.createOrder(userId, productId, count, amount);
            return "订单创建成功";
        } catch (Exception e) {
            log.error("订单创建失败", e);
            return "订单创建失败: " + e.getMessage();
        }
    }

}
